﻿using System.Configuration;
using System.Reflection;
using IDAL;

namespace DALFactory
{
    /// <summary>
    /// DAL创建工厂
    /// </summary>
    public class DataAccess
    {
        private static readonly string webdal;

        static DataAccess()
        {
            webdal = ConfigurationManager.AppSettings["WebDAL"];
        }

        public static IUserDAL createUserDAL()
        {
            string className = webdal + ".UserDal";
            return (IUserDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IActionDAL createActionDAL()
        {
            string className = webdal + ".ActionDal";
            return (IActionDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IResourceDAL createResourceDAL()
        {
            string className = webdal + ".ResourceDal";
            return (IResourceDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static ICategoryDAL createCategoryDAL()
        {
            string className = webdal + ".CategoryDal";
            return (ICategoryDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IKeywordDAL createKeywordDAL()
        {
            string className = webdal + ".KeywordDal";
            return (IKeywordDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static INoticeDAL createNoticeDAL()
        {
            string className = webdal + ".NoticeDal";
            return (INoticeDAL)Assembly.Load(webdal).CreateInstance(className);
        }


        public static ICommentDAL createCommentDAL()
        {
            string className = webdal + ".CommentDal";
            return (ICommentDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static ISystemLogDAL createSystemLogDAL()
        {
            string className = webdal + ".SystemLogDal";
            return (ISystemLogDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IDepartmentDAL createDepartmentDAL()
        {
            string className = webdal + ".DepartmentDal";
            return (IDepartmentDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IUserActionDAL createUserActionDAL()
        {
            string className = webdal + ".UserActionDal";
            return (IUserActionDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IFavouriteDAL createFavouriteDAL()
        {
            string className = webdal + ".FavouriteDal";
            return (IFavouriteDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IUserRelationDAL createUserRelationDAL()
        {
            string className = webdal + ".UserRelationDal";
            return (IUserRelationDAL)Assembly.Load(webdal).CreateInstance(className);
        }

        public static IDownloadHistoryDAL createDownloadHistoryDAL()
        {
            string className = webdal + ".DownloadHistoryDal";
            return (IDownloadHistoryDAL)Assembly.Load(webdal).CreateInstance(className);
        }

    }
}
